package ginx

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

var DefaultLanguage = "zh-CN"

type Api struct {
	Context *gin.Context
	Orm     *gorm.DB
	Errors  error
}

// MakeContext 设置http上下文
func (e *Api) MakeContext(c *gin.Context) *Api {
	e.Context = c
	return e
}

func (e *Api) AddError(err error) {
	if e.Errors == nil {
		e.Errors = err
	} else if err != nil {
		e.Errors = fmt.Errorf("%v; %w", e.Errors, err)
	}
}
